<template>
    <lay-card>
        <lay-button @click="getSrc">点击获取后台文件并预览</lay-button>
        <!-- pdf/text -->
        <iframe v-if="['pdf', 'text', 'log'].includes(type)" :src="src"></iframe>
    </lay-card>
</template>

<script lang="ts">
export default {
    name: "LocalDocument"
}
</script>

<script lang="ts" setup>
import { ref } from "vue";
import {getLocalDocument} from "../../../api/market/basic";


const src = ref("");
const type = ref("");

// 获取后台文件，根据实际接口处理数据
const getSrc = async (params: any) => {
  await getLocalDocument(params).then((res: any) => {
    let imgBlob = new Blob([res]);
    src.value = URL.createObjectURL(imgBlob);
  });
};


// vueOffice渲染完成的回调
const fileRendered = (e: any) => {
  console.log("渲染完成了", e);
};

// vueOffice渲染出错的回调
const fileError = (e: any) => {
  console.log("渲染出错了", e);
};
</script>

<style scoped>

</style>